﻿// Extension of generic Sprite class that adds some physics behaviour

class com.spikything.gfx3d.Ball extends com.spikything.gfx3d.Sprite {

	var f	:Number;	// Friction
	var g	:Number;	// Gravity
	var e	:Number;	// Elasticity

	function Ball () {
		super();
		vx = random(9)-4;
		vy = random(9)-4;
		vz = random(9)-4;
		f = .98;
		g = 7;
		e = -.9;
	}

	public function update () {
		vy += g;
		vx *= f;
		vy *= f;
		vz *= f;
		super.update();
		if (y>=0) {
			y = 0;
			vy *= -e;
		}
	}

	/*
	public function impulse (ix:Number, iy:Number, iz:Number):Void {
		super.impulse(ix,iy,iz);
	}

	public function setVelocities (ix:Number, iy:Number, iz:Number):Void {
		super.setVelocities(ix,iy,iz);
	}

	public function setPos (ix:Number, iy:Number, iz:Number):Void {
		super.setPos(ix,iy,iz);
	}
	*/
}